home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / NeXTcontour_1.7 / Source / TextView.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  2.3 KB  |  93 lines

  1. /*
  2. **  TextView.m, implementation of scrolling text stuff for TextLab.
  3. **  Copyright 1989 NeXT, Inc.  All Rights Reserved.
  4. **  Author: Bruce Blumberg
  5. **
  6. **  You may freely copy, distribute and reuse the code in this example.
  7. **  NeXT disclaims any warranty of any kind, expressed or implied, as to
  8. **  its fitness for any particular use.
  9. */
  10.  
  11. #import "TextView.h"
  12. #import <appkit/Font.h>
  13.  
  14. @implementation TextView:ScrollView
  15.  
  16. - initFrame:(const NXRect *)frameRect
  17. {
  18.     NXRect rect = {0.0, 0.0, 0.0, 0.0};
  19.     
  20.     /* initialize view */
  21.     [super initFrame:frameRect];
  22.     
  23.     /* specify scrollbars */
  24.     [[self setVertScrollerRequired:YES] setHorizScrollerRequired:NO];
  25.  
  26.     [self getContentSize:&(rect.size)];
  27.     theText = [self newText:&rect];
  28.     [self setDocView:theText];
  29.     [theText setSel:0 :0];    
  30.     
  31.     // The following two lines allow the resizing of the scrollview
  32.     // to be passed down to the docView (in this case, the text view 
  33.     // itself).
  34.  
  35.     [contentView setAutoresizeSubviews:YES];
  36.     [contentView setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
  37.  
  38.     // Create enclosing window and bring it upfront
  39.     [self makeEnclosingWindow:frameRect];
  40.     [[[window setTitle:"List Data"] display] makeKeyAndOrderFront:self];
  41.         
  42.     return self;
  43. }
  44.  
  45. - makeEnclosingWindow:(const NXRect *)rect
  46. {
  47.     id      textWindow;
  48.     
  49.     textWindow = [[Window alloc] initContent:rect
  50.                  style:NX_RESIZEBARSTYLE
  51.                  backing:NX_BUFFERED
  52.                  buttonMask:(NX_CLOSEBUTTONMASK|
  53.                          NX_MINIATURIZEBUTTONMASK)
  54.                  defer:NO];
  55.     [textWindow setContentView:self];
  56.     [textWindow setBackgroundGray:NX_WHITE];
  57.     [textWindow setFreeWhenClosed:YES];
  58.     
  59.     return self;
  60. }
  61.     
  62. - newText:(const NXRect *)frameRect
  63. {
  64.     id    text;
  65.     NXSize aSize = {1.0E38, 1.0E38};
  66.     
  67.     text = [[Text alloc] initFrame:frameRect
  68.                  text:NULL
  69.              alignment:NX_LEFTALIGNED];
  70.     [text setOpaque:YES];
  71.     [[[[[text notifyAncestorWhenFrameChanged:YES]
  72.                 setVertResizable:YES]
  73.                     setHorizResizable:NO]
  74.                     setMonoFont:NO]
  75.                         setDelegate:self];
  76.  
  77.     [text setFont:[Font newFont:"Courier" size:14.0]]; /* dcj */
  78.     
  79.     [text setMinSize:&(frameRect->size)];
  80.     [text setMaxSize:&aSize];
  81.     [text setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
  82.     
  83.     [text setCharFilter:NXEditorFilter];
  84.     return text;
  85. }
  86.  
  87. - provideTextObject
  88. {
  89.   return theText;
  90. }
  91.  
  92. @end
  93.